﻿using SisVet.ServicosModelo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SisVet.Utils
{
    public partial class frmPesquisa : Form
    {
        public frmPesquisa()
        {
            InitializeComponent();
        }

        public string CodServico { get; set; }
        public string NmServico { get; set; }
        public string Vlunitario { get; set; }     

        private void frmPesquisa_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'sisVetDataSet.Servicos' table. You can move, or remove it, as needed.
            this.servicosTableAdapter.Fill(this.sisVetDataSet.Servicos);

        }

        private void grdPesquisa_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            CodServico = grdPesquisa.SelectedRows[0].Cells[0].Value.ToString();
            NmServico = grdPesquisa.SelectedRows[0].Cells[1].Value.ToString();
            Vlunitario = grdPesquisa.SelectedRows[0].Cells[3].Value.ToString();
            this.Visible = false;
        }

        private void btnPesquisa_Click(object sender, EventArgs e)
        {
            List<Servicos> lista;
            ServicosDAL serv = new ServicosDAL();
            if (!String.IsNullOrEmpty(txtPesquisa.Text))
            {
                lista = serv.PesquisarPorNome(txtPesquisa.Text, cmbPesquisa.SelectedIndex);
            }
            else
            {
                lista = serv.ListarServicos();
            }

                grdPesquisa.DataSource = lista;
        }
    }
}
